
package cesdentalrecord.dao.view;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import org.apache.torque.TorqueException;

import test.Tester;

import cesdentalrecord.dao.controller.EditStudentController;

import cesdentalrecord.dao.Student;


public class EditStudentView {

	Student student = new Student();
	
	public void setStudent(Student s){
		this.student = s;
	}
	
	
	public void promptSuccessfulEdit() {
		System.out.println("Student information has been successfully edited.");
		
		System.out.print("Name:\t"+this.student.getSurname()+",");
		System.out.print(this.student.getFirstname()+",");
		System.out.println(this.student.getMi()+".");
		System.out.print("Birthday:\t"+this.student.getBirthmonth()+"\t");
		System.out.print(this.student.getBirthdate());
		System.out.println(this.student.getBirthyear()+",");
		System.out.println("Birthplace:\t"+this.student.getBirthplace());
		System.out.print("Grade and Section:\t"+this.student.getGrade()+",");
		System.out.println(this.student.getSection());
		System.out.println("Address:\t"+this.student.getAddress());
		System.out.println("Parent/s:\t"+this.student.getParent());
		System.out.println("Occupation:\t"+this.student.getOccupation());
		System.out.println("Medical History:\t"+this.student.getMedicalhist());
	}
	
	public void sendEditStudentRequest(Student find,int studID,String lastname,
			String firstname, String mi,String gender,String grade,String section, String month,String day,String year,String bplace, String address, String parent,
			String occupation,String medhist,int age) throws IOException, TorqueException{
		
	BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    EditStudentController esc = new EditStudentController();
    EditStudentView esv = new EditStudentView();
    /*
    String firstname;
    String mi;
    String lastname;
    String grade;
    String section;
    String year;
    String day;
    String month;
    String bplace;
    String address;
    String parent;
    String occupation;
    String medhist;
	String gender;
    */String con;
    boolean result;
    
		System.out.println("Add Student inputs:");
		SearchView search = new SearchView();
		//Student find = search.search(s);
		
		if(find != null) { /*

			esv.setStudent(find);
			Student student = new Student();
			student = find;
			String lnameE = student.getSurname();
			String fnameE = student.getFirstname();
			String miE = student.getMi();
			String genderE = student.getGender();
			String monthE = student.getBirthmonth();
			String dayE = student.getBirthdate();
			String yearE = student.getBirthyear();
			String bplaceE = student.getBirthplace();
			String gradeE = student.getGrade();
			String sectionE = student.getSection();
			String addressE = student.getAddress();
			String parentE = student.getParent();
			String occupationE = student.getOccupation();
			String medHistE = student.getMedicalhist();
			
		System.out.println("Edit inputs");
		System.out.println(lnameE);
		System.out.println("input Surname: ");
		lastname=input.readLine();
		
		System.out.println(fnameE);
		System.out.println("input Firstname: ");
		firstname=input.readLine();
		
		System.out.println(miE);
		System.out.println("input Middle Initial: ");
		mi=input.readLine();
	
		//gender
		System.out.println(genderE);
		System.out.println("input gender");
		gender=input.readLine();
	
		//grade and section
		System.out.println(gradeE);
		System.out.println("input grade");
		grade=input.readLine();
		
		System.out.println(sectionE);
		System.out.println("input section");
		section=input.readLine();
		
		//birthday
		System.out.println(monthE);
		System.out.println("input month of birth:");
		month=input.readLine();
		
		System.out.println(dayE);
		System.out.println("input day of birth:");
		day=input.readLine();
		
		System.out.println(yearE);
		System.out.println("input year of birth:");
		year=input.readLine();
		
		System.out.println(bplaceE);
		System.out.println("input place of birth:");
		bplace=input.readLine();
		
		System.out.println(addressE);
		System.out.println("input address:");
		address=input.readLine();
		
		System.out.println(parentE);
		System.out.println("input parent/guardian's name:");
		parent=input.readLine();
		
		System.out.println(occupationE);
		System.out.println("input occupation:");
		occupation=input.readLine();
		
		System.out.println(medHistE);
		System.out.println("input Medical History:");
		medhist=input.readLine();
		*/
		//System.out.println("To Confirm: Input yes.");
		//con=input.readLine();
		
		/*if(con.equals("yes")){*/
		result = esc.validateEditStudentEntries(find,studID,lastname,
				firstname,mi,gender,grade,section,month,day,year,bplace,address,parent,
				occupation,medhist,age);/*
			if(result){
				esv.promptSuccessfulEdit();
			}else System.out.println("Edit unsuccessful.");
		
		}else {
			Tester test = new Tester();
			test.menu();
			}*/
	}
	else{
	System.out.println("Student not found");
		}
	}		

}

